//
//  ChangeEnvTableViewCell.m
//  ChangeEnvironmentManager
//
//  Created by simon on 2022/2/25.
//

#import "ChangeEnvTableViewCell.h"
#import "ChangeEnvironmentManager.h"


@implementation ChangeEnvTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        if (@available(iOS 14.0, *)) {
            self.backgroundConfiguration = [UIBackgroundConfiguration clearConfiguration];
        } else {
            // 默认
            self.backgroundColor = [UIColor whiteColor];
        }
        //默认透明
        self.contentView.backgroundColor = [UIColor whiteColor];
        [self setUI];
    }
    return self;
}
- (void)setUI{
    
}

- (void)setData:(ZXChangeEnvironmentModel *)model
{
    self.textLabel.text= model.title;
    self.textLabel.textColor = [UIColor blackColor];
    self.detailTextLabel.text = model.hostUrl;
    self.detailTextLabel.textColor = [UIColor blackColor];
    if (model.isSelected) {
        self.accessoryType = UITableViewCellAccessoryCheckmark;
    }
    else{
        self.accessoryType = UITableViewCellAccessoryNone;
    }
}

//- (void)setDataWithTableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//    
//    NSDictionary *hostDic = [[ChangeEnvironmentManager allApiEnvConfigu]objectAtIndex:indexPath.row];
//    NSString *title = [hostDic objectForKey:@"title"];
//    NSString *host = [hostDic objectForKey:@"host"];
//
//
//    self.textLabel.text= title;
//    self.textLabel.textColor = [UIColor blackColor];
//    self.detailTextLabel.text = host;
//    self.detailTextLabel.textColor = [UIColor blackColor];
//
//    if ([self isCurrentEnvWithItemHost:host]) {
//        self.accessoryType = UITableViewCellAccessoryCheckmark;
//        [tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
//    }
//    else{
//        self.accessoryType = UITableViewCellAccessoryNone;
//    }
//}
//

//- (BOOL)isCurrentEnvWithItemHost:(NSString *)host{
//    ApiEnv apiEnv = [ChangeEnvironmentManager apiEnv];
//    
//    if (apiEnv == ApiEnvProd &&[host isEqualToString:[ChangeEnvironmentManager sharedInstance].onlineHost]) {
//        return YES;
//    }
//    else if (apiEnv == ApiEnvPre &&[host isEqualToString:[ChangeEnvironmentManager sharedInstance].preHost]) {
//        return YES;
//    }
//    else if (apiEnv == ApiEnvDaily && [host isEqualToString:[ChangeEnvironmentManager sharedInstance].dailyHost]) {
//        return YES;
//    }
//    else if (apiEnv == ApiEnvDev && [host isEqualToString:[ChangeEnvironmentManager sharedInstance].devHost]) {
//        return YES;
//    }
//    return NO;
//}

@end
